package com.liujit.pay.wx.domain.params.order;

import cn.hutool.json.JSONObject;
import lombok.Builder;

/**
 * @description: 支付者
 * @author: liujun
 * @create: 2021-02-20 09:49
 */
@Builder
public class OrderPayer {

    /**
     * 用户在直连商户appId下的唯一标识
     */
    private String openId;

    OrderPayer(String openId) {
        this.openId = openId;
    }

    /**
     * 初始化参数
     *
     * @param openId 用户标识
     * @return
     */
    public static OrderPayer.Builder builder(String openId) {
        return new OrderPayer.Builder(openId);
    }

    public static class Builder {

        private String openId;

        Builder(String openId) {
            this.openId = openId;
        }

        public OrderPayer build() {
            return new OrderPayer(this.openId);
        }
    }

    /**
     * 转化JSON字符串
     *
     * @return
     */
    public String toJSONString() {
        JSONObject json = new JSONObject();
        // 用户标识
        json.set("openid", openId);
        return json.toString();
    }
}
